/**  
 *	VisualGroup JavaScript prototype Classes, version 0.1
 *  (c) 2008 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/
using("Vsg.Component");

Vsg.Component.DateBasicPanel = Ext.extend(Ext.grid.GridPanel,{
	
	defaultMethod:function($config) {
		// --- defind basic defined ---
		if ($config == null) {
			throw "Do not defined a basic config for object!";
		}
		
		var $_con = {
			id:"Vsg.Component.DateBasicPanel",
			height:"100%",
			iconCls:"icon-grid",
			viewConfig:{forceFit:true},
			sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
			colModel:new Ext.grid.ColumnModel([
				new Ext.grid.CheckboxSelectionModel() ,
				{
					id:"code",
					header: "股票代码",
					width: 25,
					sortable: true,
					dataIndex: "code"
				},
				{
					header: "日期",
					width: 25,
					sortable: true, 
					dataIndex: "stockdate"
				},
				{
					header: "开盘价(点)",
					width: 25,
					sortable: true,
					dataIndex: "open"
				
				},
				{
					header: "收盘价(点)",
					width: 25,
					sortable: true,
					dataIndex: "close"
				
				},				
				{
					header: "成交量",
					width: 25,
					sortable: false,
					dataIndex: "vol"
				},
				{
					header: "平均单笔量",
					width: 25,
					sortable: false,
					dataIndex: "dayAverTick"
				}				
			])
		};


		try {

			$_con.id = $config.id != null ? $config.id : "Vsg.Component.DateBasicPanel";
			
			// --- add top tool bar ----
			/*
			var $tbar = this.initToolBar();
			if ($tbar instanceof Array && $tbar.length > 0) {
				$_con.tbar = $tbar;
			}
			*/			
			
			for (var $i in $config) {
				$_con[$i] = $config[$i];
			}
			
		} catch (e) {
			// -- catch default value defined ---
			alert(e);
		}
		return $_con;		
			
	},
	
	
	constructor:function($config) {

		var $attrs = this.defaultMethod($config);

		Vsg.Component.DateBasicPanel.superclass.constructor.apply(this, $attrs);

		
	},
	
	
	
	initToolBar:function() {
		
		var $toolbar = [];
		var $event = null;
		
		try {
			var $menuItems = [];
			
			$event = Vsg.getDefinedEvent("Vsg.Component.DateBasicPanel.evt_addClientTrade");
			var $sbtn = Vsg.authComponent(
				{
					text:"新增行业信息" , 
					iconCls:"add",
					id:"btnAddClientTrade",
				 	handler:$event, 
				 	xtype:"button"
				}, 
				 "Vsg.Component.DateBasicPanel.btnAddClientTrade"
			);
			if ($sbtn != null) {
				$menuItems.push($sbtn);
			}			

			$event = Vsg.getDefinedEvent("Vsg.Component.DateBasicPanel.evt_updateClientTrade");			
			$sbtn = Vsg.authComponent(
			{
				 text:"更新行业信息", 
				 iconCls:"option", 
				 id:"btnUpdateClientTrade" ,
				 handler:$event , 
				 xtype:"button"
			},
			"Vsg.Component.DateBasicPanel.btnUpdateClientTrade");
			if ($sbtn != null) {
				$menuItems.push($sbtn);
			}

			$event = Vsg.getDefinedEvent("Vsg.Component.DateBasicPanel.evt_removeClientTrade");			
			$sbtn = Vsg.authComponent(
			{ 
				text:"移除行业信息", 
				iconCls:"remove" ,
				id:"btnRemoveClientTrade" , 
				handler:$event , 
				xtype:"button"}, 
			"Vsg.Component.DateBasicPanel.btnRemoveClientTrade");
			if ($sbtn != null) {
				$menuItems.push($sbtn);
			}				
			
			$toolbar.push({text:"基本操作" , menu:$menuItems , iconCls: "bmenu"});

		} catch(ex) {
			Ext.log("创建菜单[基本操作] 出错 : " + ex);
		}

		return $toolbar;
	}
});